package p270jp.pxv.android.viewholder;

import android.content.Context;
import android.util.TypedValue;
import android.view.View;
import android.widget.ImageView;
import androidx.recyclerview.widget.RecyclerView;
import java.util.Calendar;
import java.util.concurrent.TimeUnit;
import p165fo.C3114c;
import p270jp.pxv.android.R;
import p270jp.pxv.android.event.ShowPixivisionEvent;
import p270jp.pxv.android.model.Pixivision;
import p314lg.ViewPixivisionBinding;
import p325m0.MutabilityOwnership;
import p677zi.PixivImageLoader;

/* compiled from: HomePixivisionListItemViewHolder.kt */
/* renamed from: jp.pxv.android.viewholder.HomePixivisionListItemViewHolder */
/* loaded from: classes2.dex */
public final class HomePixivisionListItemViewHolder extends RecyclerView.AbstractC0819y {
    public static final int $stable;
    private final ViewPixivisionBinding binding;
    private final PixivImageLoader pixivImageLoader;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public HomePixivisionListItemViewHolder(ViewPixivisionBinding vaVar, PixivImageLoader aVar) {
        super(vaVar.f2666e);
        MutabilityOwnership.m3745m(vaVar, "binding");
        MutabilityOwnership.m3745m(aVar, "pixivImageLoader");
        this.binding = vaVar;
        this.pixivImageLoader = aVar;
    }

    /* renamed from: bindPixivision$lambda-0 */
    public static final void m12313bindPixivision$lambda0(Pixivision pixivision, View view) {
        MutabilityOwnership.m3745m(pixivision, "$pixivision");
        C3114c.m6284b().m6280f(new ShowPixivisionEvent(pixivision));
    }

    public final void bindPixivision(Pixivision pixivision) {
        MutabilityOwnership.m3745m(pixivision, "pixivision");
        PixivImageLoader aVar = this.pixivImageLoader;
        Context context = this.itemView.getContext();
        MutabilityOwnership.m3746l(context, "itemView.context");
        String thumbnail = pixivision.getThumbnail();
        ImageView imageView = this.binding.f22363r;
        MutabilityOwnership.m3746l(imageView, "binding.imageView");
        aVar.m59g(context, thumbnail, imageView);
        this.binding.f22367v.setText(pixivision.getTitle());
        this.itemView.setOnClickListener(new View$OnClickListenerC4406g(pixivision, 1));
        this.binding.f22366u.setText(pixivision.getSubcategoryLabel());
        String category = pixivision.getCategory();
        int hashCode = category.hashCode();
        if (hashCode != -1860080918) {
            if (hashCode != -919958188) {
                if (hashCode == 193276766 && category.equals("tutorial")) {
                    this.binding.f22362q.setBackgroundResource(R.color.guideline_pixivision_tutorial_green);
                    this.binding.f22366u.setBackgroundResource(R.color.guideline_pixivision_tutorial_green);
                }
            } else if (category.equals("spotlight")) {
                Context context2 = this.itemView.getContext();
                MutabilityOwnership.m3746l(context2, "this.itemView.context");
                TypedValue typedValue = new TypedValue();
                if (context2.getTheme().resolveAttribute(R.attr.colorCharcoalBrand, typedValue, true)) {
                    int i = typedValue.data;
                    this.binding.f22362q.setBackgroundColor(i);
                    this.binding.f22366u.setBackgroundColor(i);
                } else {
                    throw new IllegalStateException("Charcoal Theme, もしくは Charcoal Bridge Theme を利用してください");
                }
            }
        } else if (category.equals("inspiration")) {
            this.binding.f22362q.setBackgroundResource(R.color.guideline_pixivision_inspiration_orange);
            this.binding.f22366u.setBackgroundResource(R.color.guideline_pixivision_inspiration_orange);
        }
        long currentTimeMillis = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(1);
        Calendar instance = Calendar.getInstance();
        instance.setTime(pixivision.getPublishDate());
        this.binding.f22364s.setVisibility(instance.getTimeInMillis() < currentTimeMillis ? 8 : 0);
    }
}
